package cn.ly.jmockittest.util;

import cn.ly.easymocktest.User;
import cn.ly.jmockittest.Dao;
import cn.ly.jmockittest.LoginDao;
import mockit.Mock;
import mockit.MockUp;

/**
 * Created by liuyu21 on 2017/10/22.
 */
public class MockTool {

    public static Dao getDao(Long id,String userName,String password){
        MockUp<Dao> mockUp = new MockUp<Dao>() {
            @Mock
            public int getStoreCount(String group) {
                return 2000;
            }
            @Mock
            public User getUser(Long id){
                return User.newBuilder()
                        .withUserId(id).withUserName(userName).withPassword(password).build();
            }
        };
        return mockUp.getMockInstance();
    }

    public static LoginDao getLoginDao(){
        MockUp<LoginDao> loginDaoMockUp = new MockUp<LoginDao>() {
            @Mock
            public boolean login(User user){
                return true;
            }
        };
        return loginDaoMockUp.getMockInstance();
    }

}
